class Solution:
    def rectCover(self, n):
        # write code here
        first = 0
        second = 1
        res = 0
        while True:
            res = first + second
            if n <= res:
                break
            first = second
            second = res
        print(min(res - n, n - second))



s= Solution()
m =s.rectCover(21)
